home *** CD-ROM | disk | FTP | other *** search
- {$G+,X+,F+}
-
- {Conditional defines that may affect this unit}
- {$I AWDEFINE.INC}
-
- {*********************************************************}
- {* TCOMINI.PAS 1.01 *}
- {* Copyright (c) TurboPower Software 1995 *}
- {* All rights reserved. *}
- {*********************************************************}
-
- unit TcomIni;
- {-INI file and configuration data for TCOM}
-
- interface
-
- uses
- WinTypes,
- WinProcs,
- SysUtils,
- Graphics,
- OoMisc,
- AdMisc,
- AdModDB,
- AdPort,
- AdTerm,
- AdDial,
- AdProtcl;
-
- {.INI file parameters}
- const
- IniName = 'TCOM.INI';
-
- tsTerminal = 'DelphiTerminal';
- tsPort = 'Port';
- tsFlow = 'Flow control';
- tsDev = 'Device layer';
- tsDirs = 'Directories';
- tsModem = 'Modem';
- tsDialer = 'Dialer';
- tsProtocols = 'Protocols';
- tsZmodem = 'Zmodem';
- tsBplus = 'B+';
- tsKermit = 'Kermit';
- tsAscii = 'ASCII';
-
- tkFontColor = 'Color'; tdFontColor = $00C0C0C0; {!!.01}
- tkFontHeight = 'Height'; tdFontHeight = -12;
- tkFontName = 'Name'; tdFontName = 'Terminal';
- tkFontStyle = 'Style'; tdFontStyle = [];
- (*tkEmulation = 'Emulation'; tdEmulation = etAnsi; {!!.01}*)
-
- tkComPort = 'ComPort'; tdComPort = 'COM1';
- tkBaudRate = 'BaudRate'; tdBaudRate = 1200;
- tkParity = 'Parity'; tdParity = pNone;
- tkDataBits = 'DataBits'; tdDataBits = 8;
- tkStopBits = 'StopBits'; tdStopBits = 1;
-
- tkHWFlow = 'HWFlowCtl'; tdHWFlow = 'CTS/RTS';
-
- tkSWFlowRecCtl = 'ReceiveSwFlowCtl'; tdSWFlowRecCtl = False;
- tkSWFlowXmitCtl = 'TransmitSwFlowCtl'; tdSWFlowXmitCtl = False;
- tkXonChar = 'XonChar'; tdXonChar = 17;
- tkXoffChar = 'XoffChar'; tdXoffChar = 19;
-
- tkDevice = 'Device'; tdDevice = dlComm;
- tkBufSize = 'BufSize'; tdBufSize = 16384;
-
- tkUploadDir = 'UploadDir';
- tkDownloadDir = 'DownloadDir';
-
- tkRetries = 'Retries'; tdRetries = 10;
- tkRetryWait = 'RetryWait'; tdRetryWait = 60;
- tkAbortOnVoice = 'AbortOnVoice'; tdAbortOnVoice = False;
- tkAbortOnBusy = 'AbortOnBusy'; tdAbortOnBusy = False;
- tkAbortOnNC = 'AbortOnNoCarrier'; tdAbortOnNC = False;
- tkAbortOnND = 'AbortOnNoDialTone'; tdAbortOnND = True;
- tkAbortOnError = 'AbortOnError'; tdAbortOnError = True;
-
- tkOverwriteMode = 'OverwriteFiles'; tdOverwriteMode = wfWriteFail;
- tkSavePartials = 'SavePartials'; tdSavePartials = False;
- tkRTSWrite = 'RTSWhenWriting'; tdRTSWrite = True;
-
- tkZmodemAutoSt = 'AutoStart'; tdZmodemAutoSt = True;
-
- tkBplusEnabled = 'Enabled'; tdBplusEnabled = True;
-
- tkKermitErrChk = 'ErrorCorrection'; tdKermitErrChk = '1';
- tkHiBitPrefix = 'HiBitPrefix'; tdHiBitPrefix = 89;
- tkRepeatPrefix = 'RepeatPrefix'; tdRepeatPrefix = 126;
- tkControlPrefix = 'ControlPrefix'; tdControlPrefix = 35;
- tkPaddingCount = 'PaddingCount'; tdPaddingCount = 0;
- tkPaddingChar = 'PaddingChar'; tdPaddingChar = 0;
- tkMaxPackLength = 'MaxPacketLength'; tdMaxPackLength = 80;
- tkTerminator = 'Terminator'; tdTerminator = 13;
-
- tkUploadCR = 'UploadCR'; tdUploadCR = aetNone;
- tkUploadLF = 'UploadLF'; tdUploadLF = aetNone;
- tkStopCtrlZ = 'StopOnCtrlZ'; tdStopCtrlZ = True;
- tkEolCharacter = 'EolChar'; tdEolCharacter = 13;
- tkDelayChar = 'DelayAfterChar'; tdDelayChar = 0;
- tkDelayLine = 'DelayAfterLine'; tdDelayLine = 0;
- tkDownloadCR = 'DownloadCR'; tdDownloadCR = aetNone;
- tkDownloadLF = 'DownloadLF'; tdDownloadLF = aetNone;
- tkTimeout = 'DownloadTimeout'; tdTimeout = 2000;
-
- {enumerated strings for INI file}
- ePitches = 'DEFAULT|VARIABLE|FIXED';
- eEmulations = 'NONE|ANSI|VT52|VT100';
- eParities = 'NONE|ODD|EVEN|MARK|SPACE';
- eDevices = 'NONE|COMMDRV|FOSSIL';
- eOverwriteModes = 'NONE|FAIL|RENAME|OVERWRITE|RESUME';
- eKermitCheck = 'CSUM|CSUM2|CRC';
- eUplCRXlat = 'SEND|STRIP|BOOGA|SENDLF';
- eUplLFXlat = 'SEND|STRIP|SENDCR';
- eDwnCRXlat = 'KEEP|STRIP|BOOGA|ADDLF';
- eDwnLFXlat = 'KEEP|STRIP|ADDCR';
-
- {Misc}
- BatchProtocols : Set of TProtocolType = [ptYModem, ptYmodemG, ptZmodem, ptKermit];
-
- var
- {terminal}
- FontData : TFont;
- (*Emulation : TEmulatorType; {!!.01}*)
-
- {Com parameters}
- Com : String[4];
- Baud : LongInt;
- Parity : TParity;
- Databits : Byte;
- Stopbits : Byte;
-
- {Flow parameters}
- HdwFlow : THWFlowOptionSet;
- SfwFlow : TSWFlowOptions;
- XonChar : Char;
- XoffChar : Char;
-
- {Buffer sizes}
- InBuff : Word;
- OutBuff : Word;
- BufferFull : Word;
- BufferResume : Word;
-
- {Device}
- Device : TDeviceLayer;
-
- {Dirs}
- UploadDir : String[66];
- DownloadDir : String[66];
-
- {Modem}
- ModemInfo : TModemInfo;
- DBFile : TFileName;
-
- {Phonebook}
- PhoneFile : TFileName;
-
- {Capture}
- CaptureFile : TFileName;
-
- {$IFDEF Tracing}
- TraceFile : TFileName;
- {$ENDIF}
- {$IFDEF DispatchLogging}
- DispLogFile : TFileName;
- {$ENDIF}
-
- {Dialer}
- MaxDialTries : Integer;
- RetryTime : Integer;
- DialerOpts : TDialerOptions;
-
- {Protocol options}
- WriteOpt : TWriteFailAction;
- SavePartials : Boolean;
- RTSWrite : Boolean;
- LogFile : TFileName;
-
- {Zmodem options}
- ZmodemAutoSt : Boolean;
-
- {B+ options}
- BplusEnabled : Boolean;
-
- {Kermit options}
- ErrCheck : Char;
- HiBitPrefix : Char;
- RepeatPrefix : Char;
- CtlPrefix : Char;
- PadCount : Byte;
- PadChar : Char;
- MaxPacketLen : Byte;
- Terminator : Char;
-
- {ASCII options}
- UploadCR : TAsciiEOLTranslation;
- UploadLF : TAsciiEOLTranslation;
- StopCtrlZ : Boolean;
- EolChar : Char;
- DelayChar : Word;
- DelayLine : Word;
- DownloadCR : TAsciiEOLTranslation;
- DownloadLF : TAsciiEOLTranslation;
- AscTimeout : Word;
-
- const
- IniBoolStr : array[False..True] of String[10] = ('FALSE', 'TRUE');
- EnumDelim = '|';
-
- type
- ENoIniSection = class(Exception) end;
-
- {INI file manager}
- TIniFile = class(TObject)
- private
- FFileName : array[0..79] of Char;
- FSection : array[0..255] of Char;
- TempVar : array[0..255] of Char;
- TempData : array[0..255] of Char;
- TempDefault : array[0..255] of Char;
-
- function ReadSection : String;
- procedure SetSection(const Sect : String);
- function ReadFileName : TFileName;
- procedure SetFileName(const FName : TFileName);
-
- public
- property FileName : TFileName
- read ReadFileName write SetFileName;
- property Section : String
- read ReadSection write SetSection;
-
- constructor Create; virtual;
- destructor Destroy; virtual;
-
- {writing}
- procedure WriteString(const Variable, Data : String);
- {-Write a string to the INI file}
- procedure WriteUCString(const Variable, Data : String);
- {-Write an uppercase string to the INI file}
- procedure WriteInt(const Variable : String; Data : LongInt);
- {-Write an integer to the INI file}
- procedure WriteBoolean(const Variable : String; Data : Boolean);
- {-Write a boolean to the INI file}
- procedure WriteEnum(const Variable, Vals : String; var Data);
- {-Write an enumerated variable to the INI file}
-
- {reading}
- procedure ReadString(const Variable, DefaultVal : String; var Dest : String);
- {-Read a string from the INI file}
- procedure ReadUCString(const Variable, DefaultVal : String; var Dest : String);
- {-Read an uppercase string from the INI file}
- procedure ReadByte(const Variable : String; DefaultVal : Byte; var Dest : Byte);
- {-Read a byte from the INI file}
- procedure ReadInteger(const Variable : String; DefaultVal : Integer; var Dest : Integer);
- {-Read an integer from the INI file}
- procedure ReadWord(const Variable : String; DefaultVal : Word; var Dest : Word);
- {-Read a word from the INI file}
- procedure ReadLong(const Variable : String; DefaultVal : LongInt; var Dest : LongInt);
- {-Read a longint from the INI file}
- procedure ReadBoolean(const Variable : String; DefaultVal : Boolean; var Dest : Boolean);
- {-Read a boolean from the INI file}
- procedure ReadEnum(const Variable, Vals : String ; var DefaultVal; var Dest);
- {-Read an enumerated variable from the INI file}
- end;
-
- var
- {Configuration}
- Config : TIniFile;
-
- procedure ReadConfiguration;
- {-Read program options from TCOM.INI}
- procedure WriteTerminalOptions;
- {-Write terminal font options to TCOM.INI}
- procedure WritePortOptions;
- {-Write communications port options to TCOM.INI}
- procedure WriteFlowOptions;
- {-Write flow control options to TCOM.INI}
- procedure WriteDeviceOptions;
- {-Write device layer options to TCOM.INI}
- procedure WriteDataFileOptions;
- {-Write upload/download directory database options to TCOM.INI}
- procedure WriteDialerOptions;
- {-Write dialer options to TCOM.INI}
- procedure WriteProtocolOptions;
- {-Write general protocol options to TCOM.INI}
- procedure WriteZmodemOptions;
- {-Write Zmodem specific options to TCOM.INI}
- procedure WriteBplusOptions;
- {-Write CIS B+ specific options to TCOM.INI}
- procedure WriteKermitOptions;
- {-Write Kermit specific options to TCOM.INI}
- procedure WriteAsciiOptions;
- {-Write ASCII protocol options to TCOM.INI}
-
- function ValidBaud(Baud : LongInt) : Boolean;
- {-Return TRUE if Baud is a valid baud rate}
-
- implementation
-
- constructor TIniFile.Create;
- begin
- FileName := '';
- Section := '';
- end;
-
- destructor TIniFile.Destroy;
- begin
- end;
-
- function TIniFile.ReadSection : String;
- begin
- Result := StrPas(FSection);
- end;
-
- procedure TIniFile.SetSection(const Sect : String);
- begin
- StrPCopy(FSection, Sect);
- end;
-
- function TIniFile.ReadFileName : TFileName;
- begin
- Result := StrPas(FFileName);
- end;
-
- procedure TIniFile.SetFileName(const FName : TFileName);
- begin
- StrPCopy(FFileName, FName);
- end;
-
- procedure TIniFile.WriteString(const Variable, Data : String);
- {-Write a string to the INI file}
- begin
- if (Section = '') then
- raise ENoIniSection.Create(ReadFileName);
-
- WritePrivateProfileString(FSection, StrPCopy(TempVar, Variable),
- StrPCopy(TempData, Data), FFileName);
- end;
-
- procedure TIniFile.WriteUCString(const Variable, Data : String);
- {-Write an uppercase string to the INI file}
- begin
- WriteString(Variable, UpperCase(Data));
- end;
-
- procedure TIniFile.WriteInt(const Variable : String; Data : LongInt);
- {-Write an integer to the INI file}
- begin
- if (Section = '') then
- raise ENoIniSection.Create(ReadFileName);
-
- WriteString(Variable, IntToStr(Data));
- end;
-
- procedure TIniFile.WriteBoolean(const Variable : String; Data : Boolean);
- {-Write a boolean to the INI file}
- begin
- if (Section = '') then
- raise ENoIniSection.Create(ReadFileName);
-
- WriteString(Variable, IniBoolStr[Data]);
- end;
-
- procedure TIniFile.WriteEnum(const Variable, Vals : String; var Data);
- {-Write an enumerated variable to the INI file}
- var
- I : Integer;
- B : Byte absolute Data;
- P : Integer;
- Temp : String;
-
- begin
- if (Section = '') then
- raise ENoIniSection.Create(ReadFileName);
-
- {find the string associated with this vale}
- if (B > WordCount(Vals, [EnumDelim])) then
- Temp := ''
- else
- Temp := ExtractWord(B + 1, Vals, [EnumDelim]);
-
- {write it out}
- WriteString(Variable, Temp);
- end;
-
- procedure TIniFile.ReadString(const Variable, DefaultVal : String; var Dest : String);
- {-Read a string from the INI file}
- begin
- if (Section = '') then
- raise ENoIniSection.Create(ReadFileName);
-
- GetPrivateProfileString(FSection, StrPCopy(TempVar, Variable),
- StrPCopy(TempDefault, DefaultVal),
- TempData, 255, FFileName);
- Dest := StrPas(TempData);
- end;
-
- procedure TIniFile.ReadUCString(const Variable, DefaultVal : String; var Dest : String);
- {-Read an uppercase string from the INI file}
- begin
- if (Section = '') then
- raise ENoIniSection.Create(ReadFileName);
- ReadString(Variable, DefaultVal, Dest);
- Dest := UpperCase(Dest);
- end;
-
- procedure TIniFile.ReadByte(const Variable : String; DefaultVal : Byte; var Dest : Byte);
- {-Read a byte from the INI file}
- const
- ByteTempLen = 3;
-
- var
- Error : Integer;
- TempByte : String[ByteTempLen];
-
- begin
- ReadString(Variable, IntToStr(DefaultVal), TempByte);
- if (Length(TempByte) > ByteTempLen) and (TempByte <> '') then
- Dest := DefaultVal
- else begin
- Val(TempByte, Dest, Error);
- if (Error <> 0) then
- Dest := DefaultVal;
- end;
- end;
-
- procedure TIniFile.ReadInteger(const Variable : String; DefaultVal : Integer; var Dest : Integer);
- {-Read an integer from the INI file}
- const
- IntegerTempLen = 6;
-
- var
- Error : Integer;
- TempInteger : String[IntegerTempLen];
-
- begin
- ReadString(Variable, IntToStr(DefaultVal), TempInteger);
- if (Length(TempInteger) > IntegerTempLen) and (TempInteger <> '') then
- Dest := DefaultVal
- else begin
- Val(TempInteger, Dest, Error);
- if (Error <> 0) then
- Dest := DefaultVal;
- end;
- end;
-
- procedure TIniFile.ReadWord(const Variable : String; DefaultVal : Word; var Dest : Word);
- {-Read a word from the INI file}
- const
- WordTempLen = 5;
-
- var
- Error : Integer;
- TempWord : String[WordTempLen];
-
- begin
- ReadString(Variable, IntToStr(DefaultVal), TempWord);
- if (Length(TempWord) > WordTempLen) and (TempWord <> '') then
- Dest := DefaultVal
- else begin
- Val(TempWord, Dest, Error);
- if (Error <> 0) then
- Dest := DefaultVal;
- end;
- end;
-
- procedure TIniFile.ReadLong(const Variable : String; DefaultVal : LongInt; var Dest : LongInt);
- {-Read a longint from the INI file}
- const
- LongIntTempLen = 12;
-
- var
- Error : Integer;
- TempLongInt : String[LongIntTempLen];
-
- begin
- ReadString(Variable, IntToStr(DefaultVal), TempLongInt);
- if (Length(TempLongInt) > LongIntTempLen) and (TempLongInt <> '') then
- Dest := DefaultVal
- else begin
- Val(TempLongInt, Dest, Error);
- if (Error <> 0) then
- Dest := DefaultVal;
- end;
- end;
-
- procedure TIniFile.ReadBoolean(const Variable : String; DefaultVal : Boolean; var Dest : Boolean);
- {-Read a boolean from the INI file}
- const
- BoolTempLen = 10;
-
- var
- TempBoolean : String[BoolTempLen];
-
- begin
- ReadUCString(Variable, '', TempBoolean);
- if (TempBoolean = '') then
- Dest := DefaultVal
- else if (TempBoolean = IniBoolStr[FALSE]) then
- Dest := False
- else if (TempBoolean = IniBoolStr[TRUE]) then
- Dest := True
- else if (TempBoolean = 'TRUE') then
- Dest := True
- else if (TempBoolean = 'FALSE') then
- Dest := False
- else if (TempBoolean = 'YES') then
- Dest := True
- else if (TempBoolean = 'NO') then
- Dest := False
- else
- Dest := DefaultVal;
- end;
-
- procedure TIniFile.ReadEnum(const Variable, Vals : String ; var DefaultVal; var Dest);
- {-Read an enumerated variable from the INI file}
- var
- I : Integer;
- Cnt : Word;
- B : Byte absolute Dest;
- Temp : String;
-
- begin
- ReadUCString(Variable, '', Temp);
-
- Cnt := WordCount(Vals, [EnumDelim]);
- for I := 1 to Cnt do
- if (Temp = ExtractWord(I, Vals, [EnumDelim])) then begin
- B := Pred(I);
- Exit;
- end;
-
- B := Byte(DefaultVal);
- end;
-
- function ValidBaud(Baud : LongInt) : Boolean;
- {-Return TRUE if Baud is a valid baud rate}
- begin
- case (Baud div 10) of
- 30 ,
- 60 ,
- 120 ,
- 240 ,
- 480 ,
- 960 ,
- 1920,
- 3840,
- 5760,
- 11520: ValidBaud := True;
- else
- ValidBaud := False;
- end;
- end;
-
- {TCOM Configuration}
-
- procedure ReadConfiguration;
- {-Read program options from TCOM.INI}
-
- function ValidateComStr : Boolean;
- {-Validate the com port string from the .INI file}
- begin
- ValidateComStr := (Length(Com) = 4) and
- (Copy(Com, 1, 3) = 'COM') and
- (Com[4] in ['1'..'8']);
- end;
-
- function HdwFlowFromStr(const Str : String) : THWFlowOptionSet;
- {-Return a hardware flow control mask based on a string}
- begin
- if (Str = 'CTS') or (Str = 'CTS/RTS') or (Str = 'RTS') or (Str = 'RTS/CTS') then
- HdwFlowFromStr := [hwfUseRTS, hwfRequireCTS]
- else if (Str = 'DTR') or (Str = 'DTR/DSR') or (Str = 'DSR') or (Str = 'DSR/DTR') then
- HdwFlowFromStr := [hwfUseDTR, hwfRequireDSR]
- else
- HdwFlowFromStr := [];
- end;
-
- procedure ReadTerminalOptions;
- var
- I : Word;
- Cnt : Word;
- TempLong : LongInt;
- TempInt : Integer;
- TempStyle : TFontStyles;
- TempPitch : TFontPitch;
- TempSt : String;
-
- (*const {!!.01}
- DefEmulation : TEmulatorType = tdEmulation; {!!.01} *)
-
-
- function StrToStyle(const St : String) : TFontStyle;
- begin
- if (St = 'BOLD') then
- Result := fsBold
- else if (St = 'ITALIC') then
- Result := fsItalic
- else if (St = 'UNDERLINE') then
- Result := fsUnderline
- else
- Result := fsStrikeout;
- end;
-
- begin
- Config.Section := tsTerminal;
-
- Config.ReadLong(tkFontColor, tdFontColor, TempLong);
- FontData.Color := TempLong;
- Config.ReadInteger(tkFontHeight, tdFontHeight, TempInt);
- FontData.Height := TempInt;
- Config.ReadString(tkFontName, tdFontName, TempSt);
- FontData.Name := TempSt;
- FontData.Pitch := fpFixed;
-
- Config.ReadString(tkFontStyle, '', TempSt);
- TempStyle := [];
- Cnt := WordCount(TempSt, [',', ' ']);
- for I := 1 to Cnt do
- TempStyle := TempStyle + [StrToStyle(ExtractWord(I, TempSt, [',', ' ']))];
- FontData.Style := TempStyle;
-
- (*Config.ReadEnum(tkEmulation, eEmulations, DefEmulation, Emulation);{!!.01}*)
- end;
-
- procedure ReadPortOptions;
- {-Read communications port options from TCOM.INI}
- const
- DefParity : TParity = tdParity;
-
- begin
- Config.Section := tsPort;
-
- Config.ReadUCString(tkComPort, tdComPort, Com);
- if not ValidateComStr then
- Com := tdComPort;
-
- Config.ReadLong(tkBaudRate, tdBaudRate, Baud);
- if not ValidBaud(Baud) then
- Baud := tdBaudRate;
-
- Config.ReadEnum(tkParity, eParities, DefParity, Parity);
-
- Config.ReadByte(tkDataBits, tdDataBits, DataBits);
- if (DataBits < 5) or (DataBits > 8) then
- DataBits := 8;
-
- Config.ReadByte(tkStopBits, tdStopBits, StopBits);
- if (StopBits < 1) or (StopBits > 2) then
- StopBits := 1;
- end;
-
- procedure ReadFlowOptions;
- {-Read port flow control options from TCOM.INI}
- var
- B : Boolean;
- Temp : String[80];
-
- begin
- Config.Section := tsFlow;
-
- Config.ReadUCString(tkHWFlow, tdHWFlow, Temp);
- HdwFlow := HdwFlowFromStr(Temp);
-
- SfwFlow := swfNone;
- Config.ReadBoolean(tkSWFlowRecCtl, tdSWFlowRecCtl, B);
- if B then
- SfwFlow := swfReceive;
-
- Config.ReadBoolean(tkSWFlowXmitCtl, tdSWFlowXmitCtl, B);
- if B then
- if (SfwFlow <> swfNone) then
- SfwFlow := swfBoth
- else
- SfwFlow := swfTransmit;
-
- Config.ReadByte(tkXonChar, tdXonChar, Byte(XonChar));
- Config.ReadByte(tkXoffChar, tdXoffChar, Byte(XoffChar));
- end;
-
- procedure ReadDeviceOptions;
- {-Read device layer options from TCOM.INI}
- const
- DefDevice : TDeviceLayer = tdDevice;
-
- begin
- Config.Section := tsDev;
- Config.ReadWord(tkBufSize, tdBufSize, InBuff);
- if (InBuff = 0) then
- InBuff := 16384;
- OutBuff := 16384;
- BufferFull := LongInt(InBuff) * 80 div 100;
- BufferResume := LongInt(InBuff) * 20 div 100;
-
- Config.ReadEnum(tkDevice, eDevices, DefDevice, Device);
- end;
-
- procedure ReadDataFileOptions;
- {-Read modem, path and directory options from TCOM.INI}
- var
- Code : Integer;
- Temp : String[80];
-
- begin
- Config.Section := tsDirs;
-
- Temp := JustPathName(FullPathName(ParamStr(0)));
- Config.ReadUCString(tkUploadDir, Temp, UploadDir);
- Config.ReadUCString(tkDownloadDir, Temp, DownloadDir);
-
- Temp := AddBackslash(Temp);
-
- {$IFDEF Tracing}
- TraceFile := Temp + 'TCOM.TRC';
- {$ENDIF}
- {$IFDEF DispatchLogging}
- DispLogFile := Temp + 'TCOM.LOG';
- {$ENDIF}
- DBFile := Temp + 'AWMODEM.INI';
- LogFile := Temp + 'TCOM.HIS';
- PhoneFile := Temp + 'TCOM.PB';
- CaptureFile := Temp + 'CAPTURE.CAP';
- end;
-
- procedure ReadDialerOptions;
- {-Read modem dialer options from TCOM.INI}
- var
- AbortOnVoice : Boolean;
- AbortOnBusy : Boolean;
- AbortOnNoCarrier : Boolean;
- AbortOnNoDialTone : Boolean;
- AbortOnError : Boolean;
-
- begin
- Config.Section := tsDialer;
-
- Config.ReadInteger(tkRetries, tdRetries, MaxDialTries);
- Config.ReadInteger(tkRetryWait, tdRetryWait, RetryTime);
- Config.ReadBoolean(tkAbortOnVoice, tdAbortOnVoice, AbortOnVoice);
- Config.ReadBoolean(tkAbortOnBusy, tdAbortOnBusy, AbortOnBusy);
- Config.ReadBoolean(tkAbortOnNC, tdAbortOnNC, AbortOnNoCarrier);
- Config.ReadBoolean(tkAbortOnND, tdAbortOnND, AbortOnNoDialTone);
- Config.ReadBoolean(tkAbortOnError, tdAbortOnError, AbortOnError);
-
- if AbortOnVoice then
- DialerOpts := DialerOpts + [mdAbortOnVoice];
- if AbortOnBusy then
- DialerOpts := DialerOpts + [mdAbortOnBusy];
- if AbortOnNoCarrier then
- DialerOpts := DialerOpts + [mdAbortOnNoCarrier];
- if AbortOnNoDialTone then
- DialerOpts := DialerOpts + [mdAbortOnNoDialTone];
- if AbortOnError then
- DialerOpts := DialerOpts + [mdAbortOnError];
- end;
-
- procedure ReadProtocolOptions;
- {-Read general file transfer protocol options from TCOM.INI}
- const
- DefOverwriteMode : TWriteFailAction = tdOverwriteMode;
-
- begin
- Config.Section := tsProtocols;
-
- Config.ReadEnum(tkOverwriteMode, eOverwriteModes, DefOverwriteMode, WriteOpt);
- Config.ReadBoolean(tkSavePartials, tdSavePartials, SavePartials);
- Config.ReadBoolean(tkRTSWrite, tdRTSWrite, RTSWrite);
- end;
-
- procedure ReadZmodemOptions;
- {-Read Zmodem protocol options from TCOM.INI}
- begin
- Config.Section := tsZmodem;
- Config.ReadBoolean(tkZmodemAutoSt, tdZmodemAutoSt, ZmodemAutoSt);
- end;
-
- procedure ReadBplusOptions;
- {-Read B+ protocol options from TCOM.INI}
- begin
- Config.Section := tsBplus;
- Config.ReadBoolean(tkBplusEnabled, tdBplusEnabled, BplusEnabled);
- end;
-
- procedure ReadKermitOptions;
- {-Read Kermit protocol options from TCOM.INI}
- const
- DefKermitErrChk : Byte = Ord(tdKermitErrChk);
-
- begin
- Config.Section := tsKermit;
- Config.ReadEnum(tkKermitErrChk, eKermitCheck, DefKermitErrChk, ErrCheck);
- Inc(Byte(ErrCheck), Ord('1'));
-
- Config.ReadByte(tkHiBitPrefix, tdHiBitPrefix, Byte(HiBitPrefix));
- Config.ReadByte(tkRepeatPrefix, tdRepeatPrefix, Byte(RepeatPrefix));
- Config.ReadByte(tkControlPrefix, tdControlPrefix, Byte(CtlPrefix));
- Config.ReadByte(tkPaddingCount, tdPaddingCount, PadCount);
- Config.ReadByte(tkPaddingChar, tdPaddingChar, Byte(PadChar));
- Config.ReadByte(tkMaxPackLength, tdMaxPackLength, MaxPacketLen);
- Config.ReadByte(tkTerminator, tdTerminator, Byte(Terminator));
- end;
-
- procedure ReadAsciiOptions;
- {-Read ASCII protocol options from TCOM.INI}
- const
- DefUplCRXlat : TAsciiEOLTranslation = tdUploadCR;
- DefUplLFXlat : TAsciiEOLTranslation = tdUploadLF;
- DefDwnCRXlat : TAsciiEOLTranslation = tdDownloadCR;
- DefDwnLFXlat : TAsciiEOLTranslation = tdDownloadLF;
-
- begin
- Config.Section := tsAscii;
-
- Config.ReadEnum(tkUploadCR, eUplCRXlat, DefUplCRXlat, UploadCR);
- Config.ReadEnum(tkUploadLF, eUplLFXlat, DefUplLFXlat, UploadLF);
-
- Config.ReadBoolean(tkStopCtrlZ, tdStopCtrlZ, StopCtrlZ);
-
- Config.ReadByte(tkEolCharacter, tdEolCharacter, Byte(EolChar));
- Config.ReadWord(tkDelayChar, tdDelayChar, DelayChar);
- Config.ReadWord(tkDelayLine, tdDelayLine, DelayLine);
-
- Config.ReadEnum(tkDownloadCR, eDwnCRXlat, DefDwnCRXlat, DownloadCR);
- Config.ReadEnum(tkDownloadLF, eDwnLFXlat, DefDwnLFXlat, DownloadLF);
-
- Config.ReadWord(tkTimeout, tdTimeout, AscTimeout);
- end;
-
- begin
- if not Assigned(Config) then begin
- Config := TIniFile.Create;
- Config.FileName := IniName;
- end;
-
- ReadTerminalOptions;
- ReadPortOptions;
- ReadFlowOptions;
- ReadDeviceOptions;
- ReadDataFileOptions;
- ReadDialerOptions;
- ReadProtocolOptions;
- ReadZmodemOptions;
- ReadBplusOptions;
- ReadKermitOptions;
- ReadAsciiOptions;
- end;
-
- const
- OffOn : array[False..True] of array[0..3] of Char =
- ('OFF', 'ON');
-
- function HWFlowStr(Flow : THWFlowOptionSet) : String;
- {-Return a string based on flow control options}
- begin
- if hwfUseRTS in Flow then
- Result := 'RTS/CTS'
- else if hwfUseDTR in Flow then
- Result := 'DTR/DSR'
- else
- Result := 'NONE';
- end;
-
- procedure WriteTerminalOptions;
- {-Write terminal font options to TCOM.INI}
- const
- StyleNames : array[TFontStyle] of String[10] =
- ('BOLD', 'ITALIC', 'UNDERLINE', 'STRIKEOUT');
-
- var
- Style : TFontStyle;
- OutStyle : String;
-
- begin
- Config.Section := tsTerminal;
-
- Config.WriteInt(tkFontColor, FontData.Color);
- Config.WriteInt(tkFontHeight, FontData.Height);
- Config.WriteString(tkFontName, FontData.Name);
-
- {construct style string}
- OutStyle := '';
- for Style := fsBold to fsStrikeout do
- if Style in FontData.Style then
- OutStyle := OutStyle + StyleNames[Style] + ',';
- {remove trailing comma if necessary}
- if (Length(OutStyle) <> 0) then
- Dec(OutStyle[0]);
-
- Config.WriteString(tkFontStyle, OutStyle);
-
- (*{!!.01 - Added}
- Config.WriteEnum(tkEmulation, eEmulations, Emulation);*)
- end;
-
- procedure WritePortOptions;
- {-Write communications port options to TCOM.INI}
- begin
- Config.Section := tsPort;
-
- Config.WriteUCString(tkComPort, Com);
- Config.WriteInt(tkBaudRate, Baud);
- Config.WriteEnum(tkParity, eParities, Parity);
- Config.WriteInt(tkDataBits, DataBits);
- Config.WriteInt(tkStopBits, StopBits);
- end;
-
- procedure WriteFlowOptions;
- {-Write flow control options to TCOM.INI}
- begin
- Config.Section := tsFlow;
-
- Config.WriteUCString(tkHWFlow, HWFlowStr(HdwFlow));
- Config.WriteBoolean(tkSWFlowRecCtl, (SfwFlow = swfReceive) or (SfwFlow = swfBoth));
- Config.WriteBoolean(tkSWFlowXmitCtl, (SfwFlow = swfTransmit) or (SfwFlow = swfBoth));
- Config.WriteInt(tkXonChar, Ord(XonChar));
- Config.WriteInt(tkXoffChar, Ord(XoffChar));
- end;
-
- procedure WriteDeviceOptions;
- {-Write device layer options to TCOM.INI}
- begin
- Config.Section := tsDev;
-
- Config.WriteInt(tkBufSize, InBuff);
- Config.WriteEnum(tkDevice, eDevices, Device);
- end;
-
- procedure WriteDataFileOptions;
- {-Write upload/download directory database options to TCOM.INI}
- var
- Code : Integer;
-
- begin
- Config.Section := tsDirs;
-
- Config.WriteUCString(tkUploadDir, UploadDir);
- Config.WriteUCString(tkDownloadDir, DownloadDir);
- end;
-
- procedure WriteDialerOptions;
- {-Write dialer options to TCOM.INI}
- begin
- Config.Section := tsDialer;
-
- Config.WriteInt(tkRetries, MaxDialTries);
- Config.WriteInt(tkRetryWait, RetryTime);
- Config.WriteBoolean(tkAbortOnVoice, mdAbortOnVoice in DialerOpts);
- Config.WriteBoolean(tkAbortOnBusy, mdAbortOnBusy in DialerOpts);
- Config.WriteBoolean(tkAbortOnNC, mdAbortOnNoCarrier in DialerOpts);
- Config.WriteBoolean(tkAbortOnND, mdAbortOnNoDialTone in DialerOpts);
- Config.WriteBoolean(tkAbortOnError, mdAbortOnError in DialerOpts);
- end;
-
- procedure WriteProtocolOptions;
- {-Write general protocol options to TCOM.INI}
- begin
- Config.Section := tsProtocols;
-
- Config.WriteEnum(tkOverwriteMode, eOverwriteModes, WriteOpt);
- Config.WriteBoolean(tkSavePartials, SavePartials);
- Config.WriteBoolean(tkRTSWrite, RTSWrite);
- end;
-
- procedure WriteZmodemOptions;
- {-Write Zmodem specific options to TCOM.INI}
- begin
- Config.Section := tsZmodem;
- Config.WriteBoolean(tkZmodemAutoSt, ZmodemAutoSt);
- end;
-
- procedure WriteBplusOptions;
- {-Write CIS B+ specific options to TCOM.INI}
- begin
- Config.Section := tsBplus;
- Config.WriteBoolean(tkBplusEnabled, BplusEnabled);
- end;
-
- procedure WriteKermitOptions;
- {-Write Kermit specific options to TCOM.INI}
- var
- TempCheck : Byte;
-
- begin
- Config.Section := tsKermit;
-
- TempCheck := Ord(ErrCheck) - Ord('1');
- Config.WriteEnum(tkKermitErrChk, eKermitCheck, TempCheck);
-
- Config.WriteInt(tkHiBitPrefix, Ord(HiBitPrefix));
- Config.WriteInt(tkRepeatPrefix, Ord(RepeatPrefix));
- Config.WriteInt(tkControlPrefix, Ord(CtlPrefix));
- Config.WriteInt(tkPaddingCount, PadCount);
- Config.WriteInt(tkPaddingChar, Ord(PadChar));
- Config.WriteInt(tkMaxPackLength, MaxPacketLen);
- Config.WriteInt(tkTerminator, Ord(Terminator));
- end;
-
- procedure WriteAsciiOptions;
- {-Write ASCII protocol options to TCOM.INI}
- begin
- Config.Section := tsAscii;
-
- Config.WriteEnum(tkUploadCR, eUplCRXlat, UploadCR);
- Config.WriteEnum(tkUploadLF, eUplLFXlat, UploadLF);
- Config.WriteBoolean(tkStopCtrlZ, StopCtrlZ);
- Config.WriteInt(tkEolCharacter, Ord(EolChar));
- Config.WriteInt(tkDelayChar, DelayChar);
- Config.WriteInt(tkDelayLine, DelayLine);
- Config.WriteEnum(tkDownloadCR, eDwnCRXlat, DownloadCR);
- Config.WriteEnum(tkDownloadLF, eDwnLFXlat, DownloadLF);
- Config.WriteInt(tkTimeout, AscTimeout);
- end;
-
- initialization
- Config := nil;
- end.
-